package com.bgrconsulting.stockorderentry.service.rest.impl;

import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;


import com.bgrconsulting.stockorderentry.service.converter.OrderConverter;
import com.bgrconsulting.stockorderentry.service.converter.response.GetOrderListResponseConverter;
import com.bgrconsulting.stockorderentry.service.converter.response.OrderListResponseConverter;


import com.bgrconsulting.stockorderentry.service.model.Account;
import com.bgrconsulting.stockorderentry.service.model.SymbolInfo;
import com.bgrconsulting.stockorderentry.service.model.Order;
import com.bgrconsulting.stockorderentry.service.model.LegDetails;
import com.bgrconsulting.stockorderentry.service.model.OrderDetails;
import com.bgrconsulting.stockorderentry.service.model.response.GetOrderListResponse;
import com.bgrconsulting.stockorderentry.service.model.response.OrderListResponse;

import java.util.Date;

//@Path("/orders/rest/orderlist/")
public class GetOrderListResource {
	
	
	@GET
	 @Produces({"application/xml", "application/json"})
	 @Path("/{accountId}")  
	 public GetOrderListResponseConverter getAccount(@PathParam ("accountId") String accountId) {
		
		//TODO: Change to actually retrieve the information from an external system.
		
		
		OrderListResponse olr = new OrderListResponse();
		
		Order order1 = new Order();
		
		order1.setOrderId(320);
		order1.setOrderPlacedTime(new Date());
		order1.setLimitPrice(0.00);
		order1.setOrderStatus("OPEN");
		order1.setOrderTerm("GOOD_FOR_DAY");
		order1.setOrderType("BUY_WRITES");
		order1.setOrderValue(1068.77);
		order1.setPriceType("MARKET");
		order1.setStopPrice(0.00);
		
		LegDetails lds = new LegDetails();
		lds.setEstimatedCommision(7.99);
		lds.setEstimatedFees(0.00);
		lds.setExecutrPrice(0.00);
		lds.setFilledQuanity(0);
		lds.setLegNumber(2);
		
		SymbolInfo si = new SymbolInfo();
		si.setSymbol("IBM");
		lds.setSymbolInfo(si);
		
		order1.setLegDetails(lds);
		
		Order[] orders = new Order[2];
		orders[0] = order1;
		
		order1 = new Order();
		
		order1.setOrderId(320);
		order1.setOrderPlacedTime(new Date());
		order1.setLimitPrice(0.00);
		order1.setOrderStatus("OPEN");
		order1.setOrderTerm("GOOD_FOR_DAY");
		order1.setOrderType("BUY_WRITES");
		order1.setOrderValue(1068.77);
		order1.setPriceType("MARKET");
		order1.setStopPrice(0.00);
		
		lds = new LegDetails();
		lds.setEstimatedCommision(7.99);
		lds.setEstimatedFees(0.00);
		lds.setExecutrPrice(0.00);
		lds.setFilledQuanity(0);
		lds.setLegNumber(2);
		
		si = new SymbolInfo();
		si.setSymbol("DELL");
		lds.setSymbolInfo(si);
		
		order1.setLegDetails(lds);
		
		orders[1] = order1;
		
		OrderDetails ods = new OrderDetails(orders);
		
		olr.setCount(2);
		olr.setMarker("1270023312|296");
		
		olr.setOrderDetails(ods);
		
		GetOrderListResponse golr = new GetOrderListResponse(olr);
		
		golr.setOrderListResponse(olr);
		
		GetOrderListResponseConverter golrc = new GetOrderListResponseConverter(golr);
		
		return golrc;
		
	
	}
}
